//引入http模块
const http = require('http')
const querystring = require('querystring')

//创建server实例
const server = http.createServer((req,res)=>{
    console.log(req.method)//GET
    const url = req.url//获取请求完整的url
    console.log(url);
    req.query = querystring.parse(url.split('?')[1]) //解析querystring的参数
    console.log(req.query);
    // res.setHeader('GET',{'content/type':'text/plain'})
    res.end(JSON.stringify(req.query))//将querystring返回
})
server.listen('8000',()=>{
    console.log('server runnig in 8000');
})